/*
 * BootStrapGui.java
 *
 * Created on 11 settembre 2008, 14.54
 */
package lpr.minikazaa.bootstrap;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import lpr.minikazaa.minikazaaclient.SupernodeList;

/**
 * @date 30/04/2009
 * @author  Andrea Di Grazia, Massimiliano Giovine
 * @file BootStrapGui.java
 */
public class BootStrapGui extends javax.swing.JFrame {
    SupernodeList sn_list;
    /** Creates new form BootStrapGui */
    public BootStrapGui(SupernodeList list) {
               
        this.sn_list = list;
        
        initComponents();

        //Aggiunge un oggetto observable alla tabella
        this.sn_list.addObserver((BootstrapPeerTable)this.address_table);
        
        close_item.addActionListener(
                new ActionListener() {

                    public void actionPerformed(ActionEvent event) {
                        System.exit(0);
                    }
                });
                
         about_item.addActionListener(
                new ActionListener() {

                    public void actionPerformed(ActionEvent event) {
                        BootStrapAboutFrame about = new BootStrapAboutFrame();
                        //Il frame appare al centro dello schermo
                        about.setLocationRelativeTo(null);
                        about.setVisible(true);
                    }
                });
                
        
    }
    
    /**
     * This methods are writed by authors to extend form possibilities.
     */
    public void setWhatAppensLine(String s){
        wh.append(s);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        wh = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        address_table = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        file_menu = new javax.swing.JMenu();
        file_item = new javax.swing.JMenuItem();
        close_item = new javax.swing.JMenuItem();
        edit_menu = new javax.swing.JMenu();
        configuration_item = new javax.swing.JMenuItem();
        faq_menu = new javax.swing.JMenu();
        about_item = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("MiniKazaa - Bootstrap Server");
        setIconImage(new ImageIcon(getClass().getResource("/lpr/minikazaa/icons/mini_kazaa_main_icon.png")).getImage());
        setResizable(false);

        wh.setColumns(20);
        wh.setRows(5);
        jScrollPane1.setViewportView(wh);

        jLabel1.setText("What happens:");

        address_table = new BootstrapPeerTable();
        /*
        address_table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Indirizzo"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        */
        jScrollPane2.setViewportView(address_table);

        jLabel2.setText("Indirizzi:");

        file_menu.setText("File");

        file_item.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK));
        file_item.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lpr/minikazaa/icons/file_icon.png"))); // NOI18N
        file_item.setText("File");
        file_menu.add(file_item);

        close_item.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        close_item.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lpr/minikazaa/icons/close_icon.png"))); // NOI18N
        close_item.setLabel("Close");
        file_menu.add(close_item);

        jMenuBar1.add(file_menu);

        edit_menu.setText("Edit");

        configuration_item.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_MASK));
        configuration_item.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lpr/minikazaa/icons/config_icon.png"))); // NOI18N
        configuration_item.setText("Configuration");
        configuration_item.setName("Configuration"); // NOI18N
        edit_menu.add(configuration_item);

        jMenuBar1.add(edit_menu);

        faq_menu.setText("?");

        about_item.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lpr/minikazaa/icons/about_icon.png"))); // NOI18N
        about_item.setText("About");
        faq_menu.add(about_item);

        jMenuBar1.add(faq_menu);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem about_item;
    private javax.swing.JTable address_table;
    private javax.swing.JMenuItem close_item;
    private javax.swing.JMenuItem configuration_item;
    private javax.swing.JMenu edit_menu;
    private javax.swing.JMenu faq_menu;
    private javax.swing.JMenuItem file_item;
    private javax.swing.JMenu file_menu;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea wh;
    // End of variables declaration//GEN-END:variables
}
